<?php 

$ipFile = "lastIp.txt";

$method = $_SERVER['REQUEST_METHOD'];
if ($method == 'GET') {
	$ip = file_get_contents($ipFile);
	echo $ip;	
}
else {
	$ip = $_POST['ip'];
	$fh = fopen($ipFile, 'w') or die("can't open file");
	fwrite($fh, $ip);
	fclose($fh);
	echo $ip;
}
?>